﻿using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;

namespace BSU.GraduateWork.Data.Model
{
    [Serializable]
    [Table(Name = "Problem")]
    public class Problem:IEntity<int>
    {
        [Column(Name = "id", DbType = "Int IDENTITY", IsPrimaryKey = true, IsDbGenerated = true, 
            CanBeNull = false, AutoSync = AutoSync.OnInsert, UpdateCheck = UpdateCheck.Never)]
        public int Id { get; set;}

        [Column(Name = "Type", DbType = "int", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public ProblemType Type { get; set; }

        [Association(Name = "InputParameters_Problem", ThisKey = "InputParametersId", OtherKey = "Id", IsForeignKey = true)]
        public InputParameters InputParameters { get; set; }

        [Column(Name = "InputParametersId", DbType = "Int", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        internal int InputParametersId { get; set; }
        
        public bool IsGridRegular { get; set; }

        [Association(Name = "Solution_Problem", ThisKey = "SolutionId", OtherKey = "Id", IsForeignKey = true)]
        public Solution Solution { get; set; }

        [Column(Name = "SolutionId", DbType = "Int", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        internal int SolutionId { get; set; }

        public Problem()
        {
            Id = -1;
            Type = ProblemType.Simple;
        }
    }
}
